<?php

$this->load->helper('pdf'); 
prep_pdf();

$idu = $this->uri->segment(3,0);
$menu = $this->uri->segment(4,'apa');
$images_url = base_url('images');
$main_url = base_url('main');
$upload_url = base_url('uploads');

$detail = "";

switch($menu)
{
	case "produk":
	
		
		$produk = $this->mainmodel->get_data_produk($idu);
		
		if($produk !== FALSE)
		{
			foreach($produk AS $dproduk)
			{
				$nama = html_escape($dproduk->nama);
				$this->cezpdf->addText(250, 820, 16, $nama);
				
				$deskripsi = xss_clean($dproduk->deskripsi);
				$this->cezpdf->addText(250, 920, 16, $deskripsi);
				
				$perusahaan = $this->mainmodel->get_single_data('nama','dn_company','idperusahaan',$dproduk->idperusahaan);
				//$this->cezpdf->addText($perusahaan);
				
				$detail .= "
					<tr >
						<td class='left'>Nama Produk</td>
						<td class='right'> $nama</td>
					</tr>
					<tr >
						<td class='left'>Produk Dari </td>
						<td class='right'> <a target='_blank' href='$main_url/detail/$dproduk->idperusahaan/company/$title.html'>$perusahaan</a> </td>
					</tr>
					<tr>
						<td class='left'>Deskripsi</td>
						<td class='right'>$deskripsi</td>
					</tr>
				";
				
				if( ! empty($dproduk->gambar)){
					$gambar = BASEPATH.'uploads/produk/'.$dproduk->gambar;
					$this->cezpdf->ezImage($gambar);
				}
				
				
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	case "company":
		
		
		$usaha = $this->mainmodel->get_data_perusahaan($idu);
		
		if($usaha !== FALSE)
		{
			foreach($usaha AS $udata)
			{
				$idc = $udata->idperusahaan;
				$lowongan = "-";
				
				$nama = html_escape($udata->nama);
				$pemilik = html_escape($udata->pemilik);
				$deskripsi = xss_clean($udata->deskripsi);
				$alamat = xss_clean($udata->alamat);
				$kota = html_escape($udata->kota);
				$email = auto_link(html_escape($udata->email), 'email');
				$situs = anchor(html_escape($udata->situs), html_escape($udata->situs), 'target="_blank"');
				
				
				$kategori = html_escape($this->mainmodel->get_single_data('kategori','dn_category','idkategori',$udata->idkategori));
				
				if( ! empty($udata->logo))
				{
					$detail .= "
					<tr>
						<td class='left'><a id='lihat' href='$upload_url/perusahaan/$dloker->gambar'><img alt='logo usaha' src='$upload_url/perusahaan/$udata->logo' style='width:80%;border:0px' /></a></td>
						<td class='right'>&nbsp;</td>
					</tr>
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Nama Perusahaan</td>
						<td class='right'> $nama</td>
					</tr>
					<tr>
						<td class='left'>Kategori Usaha</td>
						<td class='right'> <a target='_blank' title='Tampilkan perusahaan dalam kategori $kategori' href='$main_url/partner.html?order=cat&kat=$udata->idkategori'>$kategori</a></td>
					</tr>
					<tr>
						<td class='left'>Pemilik</td>
						<td class='right'> $pemilik</td>
					</tr>
					<tr>
						<td class='left'>Alamat</td>
						<td class='right'>$alamat</td>
					</tr>
					<tr>
						<td class='left'>Kota</td>
						<td class='right'>$kota <a target='_blank' href='https://maps.google.com/maps?q=$kota'>[lihat peta]</a> </td>
					</tr>
					<tr>
						<td class='left'>E-mail</td>
						<td class='right'>$email</td>
					</tr>
					<tr>
						<td class='left'>Situs</td>
						<td class='right'>$situs</td>
					</tr>
					<tr>
						<td class='left'>Telp.</td>
						<td class='right'> $udata->telp</td>
					</tr>
					<tr>
						<td class='left'>Produk</td>
						<td class='right'>
							<div id='ambilproduk'><a href='$main_url/produk?order=usaha&id=$idc' id='lihatproduk'>[Lihat]</a></div>
						</td>
					</tr>
					<tr>
						<td class='left'>Info Lowongan</td>
						<td class='right'>
							<div id='ambilloker'><a href='$main_url/loker/$idc/company.html' id='lihatloker'>[Lihat]</a></div>
						</td>
					</tr>
					<tr>
						<td class='left'>&nbsp;</td>
						<td class='right'>&nbsp;</td>
					</tr>
				";
			}
			
		}else{
			$detail .= "<tr><td class='left'>&nbsp;</td><td class='right'>Data Tidak Ditemukan</td></tr>";
		}
	;
	break;
	
	case "loker":
		$mapdir .= "<a href='$main_url/loker.html'>Lowongan Kerja</a> &nbsp; &gt;&gt; <b>Detail</b>";
		$laporkan = "Konten tak layak? <a href='$main_url/lapor?link=$linklapor' >Laporkan</a>";
		$loker = $this->mainmodel->get_data_lowongan($idu);
		$hariini = date("Y-m-d");
		
		if($loker !== FALSE)
		{
			foreach($loker AS $dloker)
			{
				$perusahaan = html_escape($this->mainmodel->get_single_data('nama','dn_company','idperusahaan', $dloker->idperusahaan));
				$title = url_title($perusahaan, '-', TRUE);
				$posisi = html_escape($dloker->posisi);
				$deskripsi = xss_clean($dloker->deskripsi);
				$lokasi = html_escape($dloker->lokasi);
				$cara = auto_link(xss_clean($dloker->cara));
				$berakhir = date("d F Y", strtotime($dloker->berakhir));
				
				if($dloker->tipe == "ft")
				{
					$tipe = "Full Time";
				}else if($dloker->tipe == "pt")
				{
					$tipe = "Part Time";
				}
				else
				{
					$tipe = "Freelance";
				}
				
				if($dloker->berakhir >= $hariini)
				{
					$detail .= "
						<tr>
							<td class='left'>Berakhir</td>
							<td class='right'> <b>$berakhir</b></td>
						</tr>
						
					";
				}else{
					$detail .= "
						<tr>
							<td class='left'>Status</td>
							<td class='right'> <b>Kadaluarsa</b> (berakhir $berakhir )</td>
						</tr>
						
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Perusahan </td>
						<td class='right'> <a href='$main_url/detail/$dloker->idperusahaan/company/$title.html'>$perusahaan</a></td>
					</tr>
					<tr>
						<td class='left'>Kebutuhan</td>
						<td class='right'> $posisi</td>
					</tr>
					<tr>
						<td class='left'>Deskripsi</td>
						<td class='right'> $deskripsi</td>
					</tr>
					<tr>
						<td class='left'>Tipe Pekerjaan</td>
						<td class='right'> $tipe</td>
					</tr>
					<tr>
						<td class='left'>Lokasi Penempatan</td>
						<td class='right'> $lokasi</td>
					</tr>
					<tr>
						<td class='left'>Cara Melamar</td>
						<td class='right'> $cara</td>
					</tr>
				";	
				
				if( ! empty($dloker->gambar)){
					$detail .= "
						<tr>
							<td class='left'>Gambar</td>
							<td class='right'> <a id='lihat' href='$upload_url/lowongan/$dloker->gambar'><img alt='Gambar Lowongan' src='$upload_url/lowongan/$dloker->gambar' style='width:80%;border:0px' /></a></td>
						</tr>
					";
				}
				
				
				
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	case "acara":
		
		
		$loker = $this->mainmodel->get_data_acara($idu);
		$hariini = date("Y-m-d");
		
		if($loker !== FALSE)
		{
			foreach($loker AS $dacara)
			{
				$nama = html_escape($dacara->nama);
				$deskripsi = xss_clean($dacara->deskripsi);
				$waktu = date("d F Y H:i", strtotime($dacara->tanggal));
				$lokasi = html_escape($dacara->lokasi);
				$tanggal = date("d M Y", $waktu);
				$jam = date("H:i", $waktu);
				
				if($dacara->tanggal >= $hariini)
				{
					$detail .= "
						<tr>
							<td class='left'>Waktu Pelaksanaan</td>
							<td class='right'> <b>$waktu</b></td>
						</tr>
						
					";
				}else{
					$detail .= "
						<tr>
							<td class='left'>Waktu Pelaksanaan</td>
							<td class='right'> <b>Kadaluarsa</b> (telah dilaksanakan pada $berakhir )</td>
						</tr>
						
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Nama Acara</td>
						<td class='right'><b>$nama</b></td>
					</tr>
					
					<tr>
						<td class='left'>Waktu Pelaksanaan</td>
						<td class='right'>$tanggal Jam $jam</td>
					</tr>
					<tr>
						<td class='left'>Tempat Pelaksanaan</td>
						<td class='right'>$lokasi <a target='_blank' href='https://maps.google.com/maps?q=$lokasi'>[Lihat Peta]</a></td>
					</tr>
					<tr>
						<td class='left'>Deskripsi Acara</td>
						<td class='right'>$deskripsi</td>
					</tr>
				";	
				
				if(!empty($dacara->gambar))
				{
					$detail .= "
						<tr>
							<td class='left'>Gambar</td>
							<td class='right'> <a id='lihat' href='$upload_url/acara/$dacara->gambar'><img alt='Gambar Lowongan' src='$upload_url/acara/$dacara->gambar' style='width:60%;border:0px' /></a> </td>
						</tr>
					";
				}
				
				
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	default:
		
		$judul = "Data Tidak Ditemukan!";
		
		$detail = "
		<tr>
			<td class='left'>&nbsp;</td>
			<td class='right'>
				<b>Halaman Tidak ditemukan!</b>
			</td>
		</tr>";
		
	;
	break;
}

$this->cezpdf->ezStream();

exit(0);









$js_url = base_url('js');
$css_url = base_url('css');


$notfound = "<tr><td class='left'>&nbsp;</td><td class='right'>Data Tidak Ditemukan</td></tr>";

$mapdir = "
	<a href='$main_url'>Home</a>
	&nbsp; &gt;&gt; 
";



$other_head = "
<script type='text/javascript' src='$js_url/jquery.fancybox.js'></script>
<link rel='stylesheet' type='text/css' href='$css_url/jquery.fancybox.css' media='screen' />
<script type='text/javascript'>
	
	\$jq(function() {
		
		\$jq('a#lihat').fancybox({
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
		});
		
		\$jq('#lihatloker').click(function(){
			\$jq(this).html('<img alt=\"Loading\" src=\"$images_url/ajax-loader2.gif\" />');
			var alamat = \$jq(this).attr('href');
			\$jq('#ambilloker').load(alamat+' #loker');
			return false;
			
		});
		
		\$jq('#lihatproduk').click(function(){
			\$jq(this).html('<img alt=\"Loading\" src=\"$images_url/ajax-loader2.gif\" />');
			var alamat = \$jq(this).attr('href');
			\$jq('#ambilproduk').load(alamat+' #produk');
			return false;
			
		});
		
	});
	</script>
";




$hit = 1;

$bagikan = "
	<tr>
		<td class='left'>Bagikan : </td>
		<td class='right'>
			
			<div class='g-plusone' data-size='tall'></div> &nbsp; 
			<a href='#https://twitter.com/dadannetwork' class='twitter-share-button' data-via='DadanNetwork' data-lang='id' data-dnt='true' data-count='vertical'>Tweet</a>  &nbsp; 
			<div class='fb-like' data-send='false' data-layout='box_count' data-width='100' data-show-faces='false' data-font='arial'></div>
		</td>
	</tr>
";

switch($menu)
{
	case "produk":
	
		$mapdir .= "<a href='$main_url/produk.html'>Produk</a>  &nbsp; &gt;&gt; <b>Detail</b>";
		$produk = $this->mainmodel->get_data_produk($idu);
		
		if($produk !== FALSE)
		{
			foreach($produk AS $dproduk)
			{
				$nama = html_escape($dproduk->nama);
				$deskripsi = xss_clean($dproduk->deskripsi);
				
				$perusahaan = $this->mainmodel->get_data_single('nama','dn_company','idperusahaan',$dproduk->idperusahaan);
				$title = url_title($perusahaan, '-', TRUE);
				
				$detail .= "
					<tr >
						<td class='left'>Nama Produk</td>
						<td class='right'> $nama</td>
					</tr>
					<tr >
						<td class='left'>Produk Dari </td>
						<td class='right'> <a target='_blank' href='$main_url/detail/$dproduk->idperusahaan/company/$title.html'>$perusahaan</a> </td>
					</tr>
					<tr>
						<td class='left'>Deskripsi</td>
						<td class='right'>$deskripsi</td>
					</tr>
				";
				
				if($dproduk->gambar != ""){
					$detail .= "
					<tr>
						<td class='left'>Gambar produk</td>
						<td class='right'>: 
							<a id='lihat' href='$upload_url/produk/$dproduk->gambar'><img alt='Gambar Produk' src='$upload_url/produk/$dproduk->gambar' style='width:40%; border:0px' /></a>
						</td>
					</tr>
					";
				}
				
				
				$hit++;
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	case "company":
	
		$mapdir .= "<a href='$main_url/partner.html'>Partner</a> &nbsp; &gt;&gt; <b>Detail</b>";
		
		$usaha = $this->mainmodel->get_data_perusahaan($idu);
		if($usaha !== FALSE)
		{
			foreach($usaha AS $udata)
			{
				$idc = $udata->idperusahaan;
				$lowongan = "-";
				
				$nama = html_escape($udata->nama);
				$pemilik = html_escape($udata->pemilik);
				$deskripsi = xss_clean($udata->deskripsi);
				$alamat = xss_clean($udata->alamat);
				$kota = html_escape($udata->kota);
				$email = auto_link(html_escape($udata->email), 'email');
				$situs = anchor(html_escape($udata->situs), html_escape($udata->situs), 'target="_blank"');
				
				
				$kategori = html_escape($this->mainmodel->get_data_single('kategori','dn_category','idkategori',$udata->idkategori));
				
				if( ! empty($udata->logo))
				{
					$detail .= "
					<tr>
						<td class='left'><a id='lihat' href='$upload_url/perusahaan/$dloker->gambar'><img alt='logo usaha' src='$upload_url/perusahaan/$udata->logo' style='width:80%;border:0px' /></a></td>
						<td class='right'>&nbsp;</td>
					</tr>
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Nama Perusahaan</td>
						<td class='right'> $nama</td>
					</tr>
					<tr>
						<td class='left'>Kategori Usaha</td>
						<td class='right'> <a target='_blank' title='Tampilkan perusahaan dalam kategori $kategori' href='$main_url/partner.html?order=cat&kat=$udata->idkategori'>$kategori</a></td>
					</tr>
					<tr>
						<td class='left'>Pemilik</td>
						<td class='right'> $pemilik</td>
					</tr>
					<tr>
						<td class='left'>Alamat</td>
						<td class='right'>$alamat</td>
					</tr>
					<tr>
						<td class='left'>Kota</td>
						<td class='right'>$kota <a target='_blank' href='https://maps.google.com/maps?q=$kota'>[lihat peta]</a> </td>
					</tr>
					<tr>
						<td class='left'>E-mail</td>
						<td class='right'>$email</td>
					</tr>
					<tr>
						<td class='left'>Situs</td>
						<td class='right'>$situs</td>
					</tr>
					<tr>
						<td class='left'>Telp.</td>
						<td class='right'> $udata->telp</td>
					</tr>
					<tr>
						<td class='left'>Produk</td>
						<td class='right'>
							<div id='ambilproduk'><a href='$main_url/produk?order=usaha&id=$idc' id='lihatproduk'>[Lihat]</a></div>
						</td>
					</tr>
					<tr>
						<td class='left'>Info Lowongan</td>
						<td class='right'>
							<div id='ambilloker'><a href='$main_url/loker/$idc/company.html' id='lihatloker'>[Lihat]</a></div>
						</td>
					</tr>
					<tr>
						<td class='left'>&nbsp;</td>
						<td class='right'>&nbsp;</td>
					</tr>
				";
			}
			
		}else{
			$detail .= "<tr><td class='left'>&nbsp;</td><td class='right'>Data Tidak Ditemukan</td></tr>";
		}
	;
	break;
	
	case "loker":
		$mapdir .= "<a href='$main_url/loker.html'>Lowongan Kerja</a> &nbsp; &gt;&gt; <b>Detail</b>";
		$laporkan = "Konten tak layak? <a href='$main_url/lapor?link=$linklapor' >Laporkan</a>";
		$loker = $this->mainmodel->get_data_lowongan($idu);
		$hariini = date("Y-m-d");
		
		if($loker !== FALSE)
		{
			foreach($loker AS $dloker)
			{
				$perusahaan = html_escape($this->mainmodel->get_data_single('nama','dn_company','idperusahaan', $dloker->idperusahaan));
				$title = url_title($perusahaan, '-', TRUE);
				$posisi = html_escape($dloker->posisi);
				$deskripsi = xss_clean($dloker->deskripsi);
				$lokasi = html_escape($dloker->lokasi);
				$cara = auto_link(xss_clean($dloker->cara));
				$berakhir = date("d F Y", strtotime($dloker->berakhir));
				
				if($dloker->tipe == "ft")
				{
					$tipe = "Full Time";
				}else if($dloker->tipe == "pt")
				{
					$tipe = "Part Time";
				}
				else
				{
					$tipe = "Freelance";
				}
				
				if($dloker->berakhir >= $hariini)
				{
					$detail .= "
						<tr>
							<td class='left'>Berakhir</td>
							<td class='right'> <b>$berakhir</b></td>
						</tr>
						
					";
				}else{
					$detail .= "
						<tr>
							<td class='left'>Status</td>
							<td class='right'> <b>Kadaluarsa</b> (berakhir $berakhir )</td>
						</tr>
						
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Perusahan </td>
						<td class='right'> <a href='$main_url/detail/$dloker->idperusahaan/company/$title.html'>$perusahaan</a></td>
					</tr>
					<tr>
						<td class='left'>Kebutuhan</td>
						<td class='right'> $posisi</td>
					</tr>
					<tr>
						<td class='left'>Deskripsi</td>
						<td class='right'> $deskripsi</td>
					</tr>
					<tr>
						<td class='left'>Tipe Pekerjaan</td>
						<td class='right'> $tipe</td>
					</tr>
					<tr>
						<td class='left'>Lokasi Penempatan</td>
						<td class='right'> $lokasi</td>
					</tr>
					<tr>
						<td class='left'>Cara Melamar</td>
						<td class='right'> $cara</td>
					</tr>
				";	
				
				if( ! empty($dloker->gambar)){
					$detail .= "
						<tr>
							<td class='left'>Gambar</td>
							<td class='right'> <a id='lihat' href='$upload_url/lowongan/$dloker->gambar'><img alt='Gambar Lowongan' src='$upload_url/lowongan/$dloker->gambar' style='width:80%;border:0px' /></a></td>
						</tr>
					";
				}
				
				
				
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	case "acara":
		
		$mapdir .= "<a href='$main_url/acara.html'>Event</a> &nbsp; &gt;&gt; <b>Detail</b>";
		$laporkan = "Konten tak layak? <a href='$main_url/lapor?link=$linklapor' >Laporkan</a>";
		$loker = $this->mainmodel->get_data_acara($idu);
		$hariini = date("Y-m-d");
		
		if($loker !== FALSE)
		{
			foreach($loker AS $dacara)
			{
				$nama = html_escape($dacara->nama);
				$deskripsi = xss_clean($dacara->deskripsi);
				$waktu = date("d F Y H:i", strtotime($dacara->tanggal));
				$lokasi = html_escape($dacara->lokasi);
				$tanggal = date("d M Y", $waktu);
				$jam = date("H:i", $waktu);
				
				if($dacara->tanggal >= $hariini)
				{
					$detail .= "
						<tr>
							<td class='left'>Waktu Pelaksanaan</td>
							<td class='right'> <b>$waktu</b></td>
						</tr>
						
					";
				}else{
					$detail .= "
						<tr>
							<td class='left'>Waktu Pelaksanaan</td>
							<td class='right'> <b>Kadaluarsa</b> (telah dilaksanakan pada $berakhir )</td>
						</tr>
						
					";
				}
				
				$detail .= "
					<tr>
						<td class='left'>Nama Acara</td>
						<td class='right'><b>$nama</b></td>
					</tr>
					
					<tr>
						<td class='left'>Waktu Pelaksanaan</td>
						<td class='right'>$tanggal Jam $jam</td>
					</tr>
					<tr>
						<td class='left'>Tempat Pelaksanaan</td>
						<td class='right'>$lokasi <a target='_blank' href='https://maps.google.com/maps?q=$lokasi'>[Lihat Peta]</a></td>
					</tr>
					<tr>
						<td class='left'>Deskripsi Acara</td>
						<td class='right'>$deskripsi</td>
					</tr>
				";	
				
				if(!empty($dacara->gambar))
				{
					$detail .= "
						<tr>
							<td class='left'>Gambar</td>
							<td class='right'> <a id='lihat' href='$upload_url/acara/$dacara->gambar'><img alt='Gambar Lowongan' src='$upload_url/acara/$dacara->gambar' style='width:60%;border:0px' /></a> </td>
						</tr>
					";
				}
				
				
			}
		}else{
			$detail = $notfound;
		}
	;
	break;
	
	default:
		$detail = "
		<tr>
			<td class='left'>&nbsp;</td>
			<td class='right'>
				<b>Halaman Tidak ditemukan!</b>
			</td>
		</tr>";
		$laporkan = "&nbsp;";
		$bagikan = "&nbsp;";
	;
	break;
}

$data = 'sdfsfsf';
$this->cezpdf->addText(250, 820, 16, '<b>sdfsfdf</b>');
$this->cezpdf->ezTable($data);
$this->cezpdf->ezStream();

$isipage = "
	<div id='content2'>
			<h3>Detail Data</h3>
				
				<div class='isicontent2'>
					
					<div id='kertas' style='background-image:url($images_url/kertas.gif); background-size:100% 100%;background-position:right;' >
						
					</div>
					
					<table style='background-image:url($images_url/kertas2.gif); background-size:100% 100%;background-position:right;'>
						<tbody>
							
							$detail
							
							$bagikan 
							
							<tr>
								<td class='left'>&nbsp;</td>
								<td class='right'>
									<a href='javascript:history.go(-1)'>&lt;&lt; Kembali</a> | 
									<a href='$main_url/produk/'>Produk</a> | 
									<a href='$main_url/partner/'>Perusahaan</a> | 
									<a href='$main_url/loker.html'>Loker</a> | 
									<a href='$main_url/acara.html'>Acara</a> 
								</td>
							</tr>
							
							
						</tbody>
					</table>
				  
				  
				</div>
			</div>
";

$data['map_dir'] = $mapdir;
$data['isi_page'] = $isipage;
$data['other_head'] = $other_head;
$data['site_title'] = 'Detail Data - Dadan Network';
$data['site_description'] = 'Dadan Network adalah situs berbagi informasi tentang jaringan profesional antar enterpreneur indonesia';
$data['site_keywords'] = 'dadan, network, profesional, enterpreneur, produk, usaha';
$data['base_url'] = base_url();
$data['tahun_sekarang'] = date("Y");

$abc = $this->parser->parse('template/home', $data, TRUE);



/* End of file detail.php */
/* Location: ./application/views/main/detail.php */
